package com.example.demo.model;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2022-11-23
 * Time: 20:12
 */

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 1.给当前类标识一个注解 : 在SpringBoot启动的时候,进行初始化,把配置文件的值赋值给当前的类-->Component
 * 2.匹配哪个对象的key--->ConfigurationProperties
 */
@Component
@ConfigurationProperties(prefix = "student2")//设置一个标识->student,读yml里面的student对象
//将配置文件中的student的配置赋值给当前的对象
public class Student {

    private int id;
    private String name;
    private int age;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
